<?php
/* 类弄表
* @Author: Jerry-chen
* @Date:   2014-07-07 15:07:36
* @Last Modified time: 2014-07-12 22:58:04
* @Last Modified by: Jerry-chen<uranusbill@163.com>
* @ Copyright (c) 2014 http://www.cooldreamer.com All rightsreserved.
*/
class TypeModel extends Model
{
	//指定表名
	public $table = 'type';
	/**
	 * [add_type 添加类型]
	 */
	public function add_type()
	{
		$types = Q('post.typename');
		//正则拆分成数组
		$preg = "/(\s|\r|\n)+?/is";
		$arr = preg_split($preg, $types);
		//循环添加
		foreach ($arr as $v) {
			if(!empty($v))
			{
			$this->add(array('typename'=>$v));
			}
		}

		// return true;
		// p($arr);die;
	}
	/**
	 * [get_all 获得所有]
	 * @return [type] [description]
	 */
	public function get_all()
	{
		return $this->all();

	}
	/**
	 * [get_one 查找符合WHERE条件的值]
	 * @param  [type] $where [descrip查找符合WHERE条件的值tion]
	 * @return [type]        [description]
	 */
	public function get_one($where){

		return $this->where($where)->find();
	}
	/**
	 * [add_attr 添加属性]
	 */
	public function add_(){

		return $this->add();
	}
	/**
	 * [del_ 删除数据]
	 * @param  [type] $where [description]
	 * @return [type]        [description]
	 */
	public function delite_($where)
	{
		$this->where($where)->del();
	}
	/**
	 * [edit_ 修改]
	 * @return [type] [description]
	 */
	public function edit_($where)
	{
		$this->where($where)->save();
	}
}

?>
